﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DotNet.Core.Entity;
using DotNet.Core.Service;
using DotNet.Helper;
using DotNet.Utility;
using DotNet.Extensions;
using DotNet.JCore.Service;
using DotNet.JCore.Entity;
using DotNet.Auth.Utility;

namespace DotNet.Web.Controllers
{
    public class HistoryNotCheckDataController : BaseController
    {
        private HistoryNotCheckDataService service = new HistoryNotCheckDataService();

        public ActionResult Index()
        {
            var currentUser = AuthHelper.GetSessionUser();
            if (!currentUser.IsAdmin)
            {
                ViewBag.pointId = CurrentEmployee.PointId;
            }
            return View();
        }

        /// <summary>
        /// 获取对象分页集合
        /// </summary>
        /// <param name="name">车牌号</param>
        /// <param name="Point">检查点</param>
        /// <param name="Station">所属客运站</param>
        /// <param name="startDate">起始日期</param>
        /// <param name="endDate">截止日期</param>
        public ActionResult Grid(string CarNO, string Point, string Station, string startDate, string endDate)
        {
            var list = service.GetPageList(PageInfo(), CarNO, Point, Station, startDate.ToDateTimeOrNull(), endDate.ToDateTimeOrNull());
            return View(list);
        }

        public ActionResult Details(string id)
        {
            var entity = service.Get(id);
            if (entity == null) return NotFound(id);
            return View(entity);
        }

        public ActionResult Export(string CarNO, string Point, string Station, string startDate, string endDate)
        {
            return Export(service.GetSyncCarExitStationList(CarNO, Point, Station, startDate.ToDateTimeOrNull(), endDate.ToDateTimeOrNull()));
        }

        private ActionResult NotFound(string id)
        {
            return NotFound("获取 同步车辆出站数据信息 错误", $"无法找到 主键 = {id} 的同步车辆出站数据信息");
        }
    }
}